package com.example.springboot.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.text.SimpleDateFormat;

@Slf4j
@Component
public class MyApplicationRunner implements ApplicationRunner {
    @Autowired
    private RestTemplate restTemplate;
    public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("我是 ApplicationRunner");
        System.out.println("restTemplate : " + restTemplate);
        log.info(" 应用冷启动完成报时，当前时刻为： " +
                sdf.format(System.currentTimeMillis()));
    }
}
